package com.ruoyi.business.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.business.domain.ShopImgs;
import com.ruoyi.business.service.IShopImgsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 店铺图片Controller
 * 
 * @author ruoyi
 * @date 2024-09-11
 */
@RestController
@RequestMapping("/imgs")
public class ShopImgsController extends BaseController
{
    @Autowired
    private IShopImgsService shopImgsService;

    /**
     * 查询店铺图片列表
     */
    @RequiresPermissions("business:imgs:list")
    @GetMapping("/list")
    public TableDataInfo list(ShopImgs shopImgs)
    {
        startPage();
        List<ShopImgs> list = shopImgsService.selectShopImgsList(shopImgs);
        return getDataTable(list);
    }

    /**
     * 导出店铺图片列表
     */
    @RequiresPermissions("business:imgs:export")
    @Log(title = "店铺图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopImgs shopImgs)
    {
        List<ShopImgs> list = shopImgsService.selectShopImgsList(shopImgs);
        ExcelUtil<ShopImgs> util = new ExcelUtil<ShopImgs>(ShopImgs.class);
        util.exportExcel(response, list, "店铺图片数据");
    }

    /**
     * 获取店铺图片详细信息
     */
    @RequiresPermissions("business:imgs:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shopImgsService.selectShopImgsById(id));
    }

    /**
     * 新增店铺图片
     */
    @RequiresPermissions("business:imgs:add")
    @Log(title = "店铺图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopImgs shopImgs)
    {
        return toAjax(shopImgsService.insertShopImgs(shopImgs));
    }

    /**
     * 修改店铺图片
     */
    @RequiresPermissions("business:imgs:edit")
    @Log(title = "店铺图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopImgs shopImgs)
    {
        return toAjax(shopImgsService.updateShopImgs(shopImgs));
    }

    /**
     * 删除店铺图片
     */
    @RequiresPermissions("business:imgs:remove")
    @Log(title = "店铺图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shopImgsService.deleteShopImgsByIds(ids));
    }
}
